*****Conscription and Military Service: Do They Result in Future Violent and Non-Violent Incarcerations and Recidivism?  Wang, Flores-Lagunes 2020*****
****This do-file prints the results for Figure 6
clear all
cd "C:\Users\xinto\Dropbox\Vietnam Veteran Paper\Crime Paper\2020 JHR Data\11. Figure 6"
set matsize 1000
set more off 

global outcomes="currentViolent nonviolent_new violent_desistence nonviolent_desistance "
global outcomes1="currentViolent violent_desistence"
global outcomes2="nonviolent_new nonviolent_desistance"

do CLR_01272015.ado
do mcholx_01272015.ado

*Calculate CLR CI and bounds p-values using bootstrap data files
foreach race in 1 0 {
local i=1
 foreach outcome in $outcomes1 {


use vc_`outcome'_ygroup1_white`race'_I2_be, clear
qui bstat using vc_`outcome'_ygroup1_white`race'_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,12]
sca list N
set more off


*P3: ATT
matrix blL3=b[1,150..151]'
matrix list blL3
matrix buL3=b[1,152..153]'
matrix list buL3

matrix VblL3=Vb[150..151,150..151]
matrix list VblL3

matrix VbuL3=Vb[152..153,152..153]
matrix list VbuL3

set seed 1989
*This part compute the p-value of the CI excluding 0
local alpha=0.3
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'

local Llate3_`alpha1000'=Llate3_`alpha1000'[1,1]
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
local Ulate3_`alpha1000'=Ulate3_`alpha1000'[1,1]
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_`alpha1000''>0 {

while `CILlate3_`alpha1000''>0 & `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the lower bound excludes zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_`alpha1000''<0 {

while `CIUlate3_`alpha1000''<0 & `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the upper bound excludes zero at the level of `pvalue'" 
   } 
}

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_95=e(Lstar)
mat list Llate3_95
mat Ulate3_95=e(Ustar)
mat list Ulate3_95
mat CILlate3_95=e(CIL)
mat list CILlate3_95
mat CIUlate3_95=e(CIU)
mat list CIUlate3_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_90=e(Lstar)
mat list Llate3_90
mat Ulate3_90=e(Ustar)
mat list Ulate3_90
mat CILlate3_90=e(CIL)
mat list CILlate3_90
mat CIUlate3_90=e(CIU)
mat list CIUlate3_90



*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'
*Scatter points
gen EYT0=b[1,26]
gen L_LATE=Llate3_95[1,1]
gen U_LATE=Ulate3_95[1,1]
gen CI_L_LATE_95=CILlate3_95[1,1]
gen CI_U_LATE_95=CIUlate3_95[1,1]
gen CI_L_LATE_90=CILlate3_90[1,1]
gen CI_U_LATE_90=CIUlate3_90[1,1]

gen pvalue=`pvalue'

# delimit ; 
keep GROUP EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90
pvalue; 
# delimit cr

save Figure_AppendixD_`outcome'_`race'_4852, replace
local i=`i'+2
   } 
}   


local i=1
foreach outcome in $outcomes {
*Bar 1. nonviolent crime for white males born 
use vc_`outcome'_ygroup2_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup2_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: ATT
matrix blL3=b[1,134..135]'
matrix list blL3
matrix buL3=b[1,136..137]'
matrix list buL3

matrix VblL3=Vb[134..135,134..135]
matrix list VblL3

matrix VbuL3=Vb[136..137,136..137]
matrix list VbuL3

set seed 1989
*This part compute the p-value of the CI excluding 0
local alpha=0.3
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'

local Llate3_`alpha1000'=Llate3_`alpha1000'[1,1]
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
local Ulate3_`alpha1000'=Ulate3_`alpha1000'[1,1]
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]

*set pvalue=1
local pvalue=0.3

if `Llate3_`alpha1000''>0 & `alpha'>0 {

while `CILlate3_`alpha1000''>0 &  `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the lower bound excludes zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_`alpha1000''<0 & `alpha'>0 {

while `CIUlate3_`alpha1000''<0 &  `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the upper bound excludes zero at the level of `pvalue'" 
   } 
}
*/
CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_95=e(Lstar)
mat list Llate3_95
mat Ulate3_95=e(Ustar)
mat list Ulate3_95
mat CILlate3_95=e(CIL)
mat list CILlate3_95
mat CIUlate3_95=e(CIU)
mat list CIUlate3_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_90=e(Lstar)
mat list Llate3_90
mat Ulate3_90=e(Ustar)
mat list Ulate3_90
mat CILlate3_90=e(CIL)
mat list CILlate3_90
mat CIUlate3_90=e(CIU)
mat list CIUlate3_90

*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'
*Scatter points
gen EYT0=b[1,10]
gen L_LATE=Llate3_95[1,1]
gen U_LATE=Ulate3_95[1,1]
gen CI_L_LATE_95=CILlate3_95[1,1]
gen CI_U_LATE_95=CIUlate3_95[1,1]
gen CI_L_LATE_90=CILlate3_90[1,1]
gen CI_U_LATE_90=CIUlate3_90[1,1]

gen pvalue=`pvalue'

# delimit ; 
keep GROUP pvalue EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90; 
# delimit cr

save Figure_AppendixD_`outcome'_1_4850, replace


*Bar 1. nonviolent crime for nonwhite males born in 1948-1952 
use vc_`outcome'_ygroup2_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup2_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: ATT
matrix blL3=b[1,598..599]'
matrix list blL3
matrix buL3=b[1,600..601]'
matrix list buL3

matrix VblL3=Vb[598..599,598..599]
matrix list VblL3

matrix VbuL3=Vb[600..601,600..601]
matrix list VbuL3

set seed 1989
*This part compute the p-value of the CI excluding 2SLS
local alpha=0.3
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'

local Llate3_`alpha1000'=Llate3_`alpha1000'[1,1]
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
local Ulate3_`alpha1000'=Ulate3_`alpha1000'[1,1]
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_`alpha1000''>0 {

while `CILlate3_`alpha1000''>0 & `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the lower bound excludes zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_`alpha1000''<0 {

while `CIUlate3_`alpha1000''<0 & `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the upper bound excludes zero at the level of `pvalue'" 
   } 
}

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_95=e(Lstar)
mat list Llate3_95
mat Ulate3_95=e(Ustar)
mat list Ulate3_95
mat CILlate3_95=e(CIL)
mat list CILlate3_95
mat CIUlate3_95=e(CIU)
mat list CIUlate3_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_90=e(Lstar)
mat list Llate3_90
mat Ulate3_90=e(Ustar)
mat list Ulate3_90
mat CILlate3_90=e(CIL)
mat list CILlate3_90
mat CIUlate3_90=e(CIU)
mat list CIUlate3_90

*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'
*Scatter points
gen EYT0=b[1,474]
gen L_LATE=Llate3_95[1,1]
gen U_LATE=Ulate3_95[1,1]
gen CI_L_LATE_95=CILlate3_95[1,1]
gen CI_U_LATE_95=CIUlate3_95[1,1]
gen CI_L_LATE_90=CILlate3_90[1,1]
gen CI_U_LATE_90=CIUlate3_90[1,1]

gen pvalue=`pvalue'

# delimit ; 
keep GROUP pvalue EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90; 
# delimit cr

save Figure_AppendixD_`outcome'_0_4850, replace

local i=`i'+1

}



local i=2
foreach outcome in $outcomes2 {
*Bar 1. nonviolent crime for white males born 
use vc_`outcome'_ygroup2_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup2_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: ATT
matrix blL3=b[1,134..135]'
matrix list blL3
matrix buL3=b[1,136..137]'
matrix list buL3

matrix VblL3=Vb[134..135,134..135]
matrix list VblL3

matrix VbuL3=Vb[136..137,136..137]
matrix list VbuL3

set seed 1989
*This part compute the p-value of the CI excluding 2SLS
local alpha=0.3
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'

local Llate3_`alpha1000'=Llate3_`alpha1000'[1,1]
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
local Ulate3_`alpha1000'=Ulate3_`alpha1000'[1,1]
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]

*set pvalue=1
local pvalue=0.3

if `Llate3_`alpha1000''>0 & `alpha'>0 {

while `CILlate3_`alpha1000''>0 &  `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the lower bound excludes zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_`alpha1000''<0 & `alpha'>0 {

while `CIUlate3_`alpha1000''<0 &  `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the upper bound excludes zero at the level of `pvalue'" 
   } 
}
*/
CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_95=e(Lstar)
mat list Llate3_95
mat Ulate3_95=e(Ustar)
mat list Ulate3_95
mat CILlate3_95=e(CIL)
mat list CILlate3_95
mat CIUlate3_95=e(CIU)
mat list CIUlate3_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_90=e(Lstar)
mat list Llate3_90
mat Ulate3_90=e(Ustar)
mat list Ulate3_90
mat CILlate3_90=e(CIL)
mat list CILlate3_90
mat CIUlate3_90=e(CIU)
mat list CIUlate3_90

*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'
*Scatter points
gen EYT0=b[1,10]
gen L_LATE=Llate3_95[1,1]
gen U_LATE=Ulate3_95[1,1]
gen CI_L_LATE_95=CILlate3_95[1,1]
gen CI_U_LATE_95=CIUlate3_95[1,1]
gen CI_L_LATE_90=CILlate3_90[1,1]
gen CI_U_LATE_90=CIUlate3_90[1,1]

gen pvalue=`pvalue'

# delimit ; 
keep GROUP pvalue EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90; 
# delimit cr

save Figure_AppendixD_`outcome'_1_4850, replace


*Bar 1. nonviolent crime for nonwhite males born in 1948-1952 
use vc_`outcome'_ygroup2_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup2_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: ATT
matrix blL3=b[1,598..599]'
matrix list blL3
matrix buL3=b[1,600..601]'
matrix list buL3

matrix VblL3=Vb[598..599,598..599]
matrix list VblL3

matrix VbuL3=Vb[600..601,600..601]
matrix list VbuL3

set seed 1989
*This part compute the p-value of the CI excluding 0
local alpha=0.3
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'

local Llate3_`alpha1000'=Llate3_`alpha1000'[1,1]
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
local Ulate3_`alpha1000'=Ulate3_`alpha1000'[1,1]
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_`alpha1000''>0 {

while `CILlate3_`alpha1000''>0 & `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the lower bound excludes zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_`alpha1000''<0 {

while `CIUlate3_`alpha1000''<0 & `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the upper bound excludes zero at the level of `pvalue'" 
   } 
}

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_95=e(Lstar)
mat list Llate3_95
mat Ulate3_95=e(Ustar)
mat list Ulate3_95
mat CILlate3_95=e(CIL)
mat list CILlate3_95
mat CIUlate3_95=e(CIU)
mat list CIUlate3_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_90=e(Lstar)
mat list Llate3_90
mat Ulate3_90=e(Ustar)
mat list Ulate3_90
mat CILlate3_90=e(CIL)
mat list CILlate3_90
mat CIUlate3_90=e(CIU)
mat list CIUlate3_90

*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'
*Scatter points
gen EYT0=b[1,474]
gen L_LATE=Llate3_95[1,1]
gen U_LATE=Ulate3_95[1,1]
gen CI_L_LATE_95=CILlate3_95[1,1]
gen CI_U_LATE_95=CIUlate3_95[1,1]
gen CI_L_LATE_90=CILlate3_90[1,1]
gen CI_U_LATE_90=CIUlate3_90[1,1]

gen pvalue=`pvalue'

# delimit ; 
keep GROUP pvalue EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90; 
# delimit cr

save Figure_AppendixD_`outcome'_0_4850, replace

local i=`i'+2

}







*Panel A: white crime 1948-1952			
*Step 1: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_1_4852, clear 
append using Figure_AppendixD_nonviolent_new_1_4852
append using Figure_AppendixD_violent_desistence_1_4852
append using Figure_AppendixD_nonviolent_desistance_1_4852

collapse (mean) EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 2: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -0.1(0.1)0.2, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (A) Whites Born in 1948-1952", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_1_1, replace


*Panel B: white crime 1948-1952	
*Step 1: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_0_4852, clear 
append using Figure_AppendixD_nonviolent_new_0_4852
append using Figure_AppendixD_violent_desistence_0_4852
append using Figure_AppendixD_nonviolent_desistance_0_4852

collapse (mean) EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 2: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -1(1)2, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (B) Nonwhites Born in 1948-1952", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_1, replace


/*I: Panel A: white crime 1948-1950			
*Step 2: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_1_4850, clear 
append using Figure_AppendixD_nonviolent_new_1_4850
append using Figure_AppendixD_violent_desistence_1_4850
append using Figure_AppendixD_nonviolent_desistance_1_4850 

collapse (mean) EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -0.1(0.1)0.2, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (C) Whites Born in 1948-1950", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_1_2, replace



*I: Panel A: nonwhite crime 1948-1950	
*Step 2: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_0_4850, clear 
append using Figure_AppendixD_nonviolent_new_0_4850
append using Figure_AppendixD_violent_desistence_0_4850
append using Figure_AppendixD_nonviolent_desistance_0_4850 

collapse (mean) EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -1(1)2, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (D) Nonwhites Born in 1948-1950", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_2, replace
*/ 

*Panel C: white crime 1950		
*Step 1: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_1_1950, clear 
append using Figure_AppendixD_nonviolent_new_1_1950
append using Figure_AppendixD_violent_desistence_1_1950
append using Figure_AppendixD_nonviolent_desistance_1_1950

collapse (mean) pvalue EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 2: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -0.1(0.1)0.3, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (C) Whites Born in 1950", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_1_3, replace


*Panel D: nonwhite crime 1950		
*Step 1: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_0_1950, clear 
append using Figure_AppendixD_nonviolent_new_0_1950
append using Figure_AppendixD_violent_desistence_0_1950
append using Figure_AppendixD_nonviolent_desistance_0_1950

collapse (mean) pvalue EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 2: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -1(1)2, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (D) Nonwhites Born in 1950", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_3, replace



*Panel E: white crime 1951			
*Step 1: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_1_1951, clear 
append using Figure_AppendixD_nonviolent_new_1_1951
append using Figure_AppendixD_violent_desistence_1_1951
append using Figure_AppendixD_nonviolent_desistance_1_1951

collapse (mean) pvalue EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 2: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -0.2(0.2)0.4, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (E) Whites Born in 1951", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_1_4, replace



*Panel F: white crime 1951	
*Step 1: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_0_1951, clear 
append using Figure_AppendixD_nonviolent_new_0_1951
append using Figure_AppendixD_violent_desistence_0_1951
append using Figure_AppendixD_nonviolent_desistance_0_1951

collapse (mean) pvalue EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 2: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -2(1)3, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (F) Nonwhites Born in 1951", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_4, replace


*Panel G: white crime 1952		
*Step 1: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_1_1952, clear 
append using Figure_AppendixD_nonviolent_new_1_1952
append using Figure_AppendixD_violent_desistence_1_1952
append using Figure_AppendixD_nonviolent_desistance_1_1952

collapse (mean) EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 2: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -0.2(0.2)0.6, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (G) Whites Born in 1952", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_1_5, replace



*I: Panel H: nonwhite crime 1952		
*Step 1: Collect data for each figures within the same graph  				
use Figure_AppendixD_currentViolent_0_1952, clear 
append using Figure_AppendixD_nonviolent_new_0_1952
append using Figure_AppendixD_violent_desistence_0_1952
append using Figure_AppendixD_nonviolent_desistance_0_1952

collapse (mean) EYT0 L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_EYT0=EYT0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 2: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -2(1)3, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "E[Y|D=0]" ) size(small))  ///   
title("Panel (H) Nonwhites Born in 1952", size(medium)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_EYT0 GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_5, replace

set more off
graph combine Figure_D_1_1.gph Figure_D_0_1.gph Figure_D_1_3.gph Figure_D_0_3.gph , rows(4) cols(2) iscale(0.5) ysize(12) xsize(20)

graph combine Figure_D_1_3.gph Figure_D_0_3.gph Figure_D_1_4.gph Figure_D_0_4.gph , rows(2) cols(2) iscale(0.5) ysize(12) xsize(20)

graph combine Figure_D_1_4.gph Figure_D_0_4.gph Figure_D_1_5.gph Figure_D_0_5.gph , rows(2) cols(2) iscale(0.5) ysize(12) xsize(20)




